﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using yunbo.Model.BIP;
using yunbo.Model.PPMS;
using yunbo.Repositorys.BIPRepositorys;
using yunbo.Repositorys.PPMSRepositorys;

namespace yunbo.Controllers.PPMSControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class Mes_scjhController : ControllerBase
    {
        Mes_scjhRepository mes_scjhRepository = new Mes_scjhRepository();


        [HttpGet("GetMes_scjh")]
        public IActionResult GetMes_scjh()
        {
            List<Mes_scjh> quans = mes_scjhRepository.GetMes_scjh();
            return Ok(quans);
        }

        [HttpPost("AddMesScjh")]
        public IActionResult AddMesScjh(Mes_scjh mes_Scjh)
        {
            var quans = mes_scjhRepository.AddMesScjh(mes_Scjh);
            return Ok(quans);
        }

        [HttpGet("GetStatus")]
        public IActionResult GetStatus(string scdd_code)
        {
            var quans = mes_scjhRepository.GetStatus(scdd_code);
            return Ok(quans);
        }
        [HttpDelete("DeleteScjh")]
        public IActionResult DeleteScjh(string scdd_code)
        {
            var quans = mes_scjhRepository.DeleteScjh(scdd_code);
            return Ok(quans);
        }

        [HttpPut("UpdateStatus")]
        public IActionResult UpdateStatus(string scdd_code, int state, int update_by, string scjh_code)
        {
            int quans = mes_scjhRepository.UpdateStatus(scdd_code, state, update_by, scjh_code);
            return Ok(quans);
        }
       
         [HttpPut("UpdateMesScjh")]
        public IActionResult UpdateMesScjh(AddSCJH scjh)
        {
            int quans = mes_scjhRepository.UpdateMesScjh(scjh);
            return Ok(quans);
        }
        [HttpPut("UpdateMesScjhgd")]
        public IActionResult UpdateMesScjhgd(int gdsl, string scjhcode)
        {
            int quans = mes_scjhRepository.UpdateMesScjhgd(gdsl,scjhcode);
            return Ok(quans);
        }

        [HttpPut("UpdateMesScjhJD")]
        public IActionResult UpdateMesScjhJD(int jd, string code)
        {
            bool rs = mes_scjhRepository.UpdateMesScjhJD(jd, code)>0;
            return Ok(rs);
        }
        [HttpGet("GetJH")]
        public IActionResult GetJH(string code)
        {
            Mes_scjh rs = mes_scjhRepository.GetJH(code);
            return Ok(rs);
        }

        [HttpGet("GetJHS")]
        public IActionResult GetJHS(string code)
        {
            List<Mes_scjh> rs = mes_scjhRepository.GetJHS(code);
            return Ok(rs);
        }
    }
}
